<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
    <meta http-equiv="X-UA-Compatible" content="ie=edge,chrome=1">
    <meta name="referrer" content="never">
    <title>ES6简化对象的操作</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }
        ul {
            list-style: none;
        }
    </style>
</head>
<body>
    
    <script type="text/javascript">
        // 1. 当对象的属性名与代表属性值的变量名一致，可以只写属性名
        var age = 25;
        var uname = "object";
        var obj = {
            age: age,
            uname
        }

        console.log(obj);

        // 2. 当对象的属性值是函数类型时，可以写为 属性名(){}
        var user = {
            name: "李白",
            // say: function(){
            //     console.log(this.name);
            // },
            say(){
                console.log(this.name);
            },
            run(){
                console.log(this.name + " running");
            }
        }       
        user.say(); 
        user.run();

        
    </script>
</body>
</html>